<?
header("Content-Type: application/rss+xml; charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\r";
?>
<rss version="2.0">
  <?php
require ("../../config.php");
require ("../getUserDataFromDB.php");
require ("../getTitleOfArticle.php");
?>
<channel>
<title><?php echo $GLOBALS['setting']['web_title'] ?> - Komentáře</title>
<link><?php echo $GLOBALS['url'] ?></link>
<description><?php echo $GLOBALS['setting']['web_subTitle'] ?></description>
<language>cs</language>
<webMaster><?php echo $config['contact']['email'] ?></webMaster>
<?php
require '../seo/seo.php';
$seoParser = new SeoUrl();
$query = $GLOBALS['db']->query("SELECT * FROM " . $GLOBALS['db_prefix'] .
    "comments ORDER BY date DESC");
while ($comments = $query->fetch_array()) {
    if ((int)$comments["author_id"] == 0) {
        $author["display_name"] = "Anonym";
        $author["email"] = "anonym@anonym.com";
    } else {
        $author = getUserDataFromDB($comments["author_id"]);
    }
    $temp = ($GLOBALS['seo']) ? '' : 'index.php?q=';
    $article_title = getTitleOfArticle($comments["article_id"]);
    $seoParser->Parse($article_title);
    $seo_url = $comments["article_id"] . "-" . $seoParser->result . "#comments";
    echo "<item>\n";
    echo "<title>" . $author["display_name"] . " napsal komentář k " . $article_title .
        "</title>\n";
    echo "<link>" . str_replace("libs/rss/", "", $GLOBALS['url']) . $temp . 'content/single/' . $seo_url .
        "</link>\n";
    echo "<description>" . htmlspecialchars(strip_tags($comments["text"])) .
        "</description>\n";
    echo "<author>" . $author["email"] . " (" . $author["display_name"] .
        ")</author>\n";
    echo "<guid isPermaLink='false'>" . $comments["id"] . "</guid>\n";
    echo "<pubDate>" . date("r", strtotime($comments["date"])) . "</pubDate>\n";
    echo "</item>\n";
}

?>
</channel>
</rss>